package com.xujichang.viewbinding.samples

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding
import com.xujichang.viewbinding.ViewBindingBase

abstract class ViewBindingActivity<VB : ViewBinding> : AppCompatActivity(), ViewBindingBase<VB> {
    val TAG = this::class.simpleName
    private var _binding: VB? = null
    protected val binding: VB
        get() = _binding!!

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        createBinding(layoutInflater) {
            _binding = it
            setContentView(it.root)
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        _binding = null
    }
}